package com.aya.activity.goods.discount;

import com.aya.activity.core.GoodsPriceActivity;
import com.aya.activity.core.model.Goods;

import java.math.BigDecimal;

/**
 * 单品折扣
 */
public class Discount<T>  implements GoodsPriceActivity {

    DiscountService<T>  goodsDiscount;

    public void setGoodsDiscount(DiscountService<T>  goodsDiscount) {
        this.goodsDiscount = goodsDiscount;
    }

    @Override
    public BigDecimal activity(Goods goods, BigDecimal price) {
        return price.multiply(goodsDiscount.getDiscount(goods.getId()));
    }
}
